
<%@ include file="../common.jsp"%>
<script type="text/javascript">
	$(document).ready(
			function() {
				$("#userDetails").attr("action",'<c:url value="/saveUser.htm"></c:url>');
				$("#userName").focus();
			});
	
</script>

<form:form commandName="userDetailForm" id="userDetails">
	<table class="adminFilterTable">
		<tr class="tableChildHeaderColor">
			<td colspan="5" align="center"> ADD NEW USER </td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr> 
			<td align="left" colspan="5" style="font-family: verdana; font-size: 12px;"> All fields are mandatory.</td> 
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> User ID </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:input path="username" id="userName"/> 
				<form:errors path="username" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Name </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:input path="userDisplayName"/> 
				<form:errors path="userDisplayName"  cssClass="errorMsg"/> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Password </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:password path="password"/> 
				 <form:errors path="password"  cssClass="errorMsg"/> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> EmailID </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:input path="emailId"/> 
				<form:errors path="emailId" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Company </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField">
				<form:select path="cdId" id="companySelect" onchange="loadLocForComp(this.id,'locationSelect');">
					<form:option value="0">Choose Company</form:option>
				<c:forEach items="${companyMap}" var="companyMap">
					<form:option value="${companyMap.cdId}">${companyMap.cdName}</form:option>
				</c:forEach>
				</form:select>
				<form:errors path="cdId" cssClass="errorMsg" ></form:errors> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Business Unit </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:select path="buId" id="locationSelect" onchange="loadDepttForBU(this.id,'department');">
					<form:option value="0">Choose Location</form:option>
					<c:forEach var="locationList" items="${locationList}">
						<form:option value="${locationList.ldId}">${locationList.ldName}</form:option>
					</c:forEach>
				</form:select>
				<form:errors path="buId" cssClass="errorMsg" />
			</td>
			<td class="spacingColumnWidthLess"></td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
		<tr>
			<td class="spacingColumnWidthLess"></td>
			<td class="formLabel"> Department </td>
			<td class="spacingColumnWidthLess"></td>
			<td class="formField"> <form:select path="deptId" id="department">
				 <form:option value="0">Choose Department</form:option>
					<c:forEach var="departmentMap" items="${departmentMap}">
						<form:option value="${departmentMap.key}">${departmentMap.value}</form:option>
					</c:forEach>
				 </form:select>
				 <form:errors path="deptId" cssClass="errorMsg" /> </td>
			<td class="spacingColumnWidthLess"></td>
		</tr>	
		<tr class="formSpacingRow"><td></td> </tr>
		<tr align="left">
			<td class="spacingColumnWidthLess"></td>
			<td></td>
			<td class="spacingColumnWidthLess"></td>
			<td colspan="2">
				<input class="formButton ui-corner-all" type="button" value="SAVE" onclick="javascript:addEntity('userDetails')"></input>
			</td>
		</tr>
		<tr class="formSpacingRow"><td></td> </tr>
	</table> 
</form:form>


<c:if test="${errorCount eq 0}">
	<c:choose>
		<c:when test="${resultOfEntry}">
			Operation Done Successfully
		</c:when>
		<c:otherwise>
			<label class="errorMsg"> Error. </label>
		</c:otherwise>
	</c:choose>
</c:if>